function LikeUnlike(param) {

	var that = this;
	
	this.j_like_unlike_link = null;
	
	var like_unlike_url = "";
	
	var processing = false;
	
	var cur_like_unlike_link = null;
	
	function __construct(p) {
		for(pkey in p) {
			if(pkey[0] != "_") {
				that[pkey] = p[pkey];
			}
			if(p._like_unlike_url) {
				like_unlike_url = p._like_unlike_url;
			}
		}
		
		that.j_like_unlike_link.live('click', likeOrUnlikeLinkClick);
	}

	function likeOrUnlikeLinkClick(e) {
	try{
		e.preventDefault();
		if(!processing) {
			processing = true;
			cur_like_unlike_link = jq(this);
			var topic_id = cur_like_unlike_link.data("topic-id");
			likeOrUnlike(topic_id);
		}
	}catch(err) {
		alert(err);
	}
	}
	
	function likeOrUnlike(topic_id) {
	try{
		jq.get(like_unlike_url, { 'topic_id' : topic_id }, likeOrUnlikeSuccess)
	    .error(function() {
			var pos_top = cur_like_unlike_link.offset().top;
			jq.notification({ "pos_top" : pos_top, "width" : 360, "message" : "Oops! An error occurred while processing your request." });
	    })
	    .complete(function() {
	   		// complete
	    	processing = false;
	    });
	}catch(err) {
		alert(err);
	}
	}
	
	function likeOrUnlikeSuccess(data) {
	try{
		if(data === "SUCCESS") {
			if(cur_like_unlike_link.hasClass("like")) {
				cur_like_unlike_link.removeClass("like");
				cur_like_unlike_link.addClass("unlike");
			}else if(cur_like_unlike_link.hasClass("unlike")) {
				cur_like_unlike_link.removeClass("unlike");
				cur_like_unlike_link.addClass("like");
			}
		}else if(data === "UNAUTHORIZED") {
			var pos_top = cur_like_unlike_link.offset().top;
			jq.notification({ "pos_top" : pos_top, "width" : 360, "message" : "Please login before attempting this operation." });
		}
	}catch(err) {
		alert(err);
	}	
	}
	
	__construct(param);
	
}
